#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT(tinydom, 0.4.1, TakashiC.Ito@gmail.com)
AC_CONFIG_AUX_DIR([config])
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([tdom.c])
AC_CONFIG_HEADER([config.h])
AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov],[turn on code coverage analysis tools]))

# Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_DISABLE_SHARED
AC_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)
PKG_PROG_PKG_CONFIG

# Checks for libraries.
AC_CHECK_LIB(expat, XML_Parse, , AC_MSG_ERROR(expat not found))
PKG_CHECK_MODULES(LIBEVENT,libevent)

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdint.h stdlib.h string.h])
AC_CHECK_HEADERS([assert.h sys/queue.h])
AC_CHECK_HEADERS([expat.h event.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T

# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset strcasecmp strchr strdup])

dnl Check for --enable-gcov and add appropriate flags for gcc
if test "x$enable_gcov" = "xyes"; then
  CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
fi

AC_CONFIG_FILES([Makefile tinydom.pc])
AC_OUTPUT
